package top.codedance.iotp.tools.clientStatusMonitor.plugin;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.ImageObserver;
import java.io.File;
import java.io.IOException;

public class StaticImageJLabel extends JLabel {
    private String image;
    private int with;
    private int height;

    public StaticImageJLabel(String image, int width, int height) {
        this.image = image;
        this.with = width;
        this.height = height;
        setSize(this.with, this.height);
        setBounds(0, 0, this.with, this.height);
    }

    public void paint(Graphics g) {
        ImageObserver imageObserver = (img, infoflags, x, y, width, height) -> false;
        try {
            g.drawImage(ImageIO.read(new File(this.image)), 0, 0, this.with, this.height, imageObserver);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
